package org.sample.traffic;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created by alan on 2017/7/11.
 */
public class LampController {

    private static final ScheduledExecutorService timer = Executors.newScheduledThreadPool(1);

    private Lamp currentLamp;

    public LampController() {
        this.currentLamp = Lamp.S2N;
    }

    public void start() {
        currentLamp.light();

        timer.scheduleAtFixedRate(() -> {

            currentLamp = currentLamp.blackOut();

        }, 4, 4, TimeUnit.SECONDS);
    }
}